package org.haifi.game.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.mina.core.session.IoSession;
import org.haifi.game.model.GameUser;
import org.haifi.game.model.Player;
import org.haifi.game.util.SessionUtils;

public class GameBaseAction {
	protected final Log log = LogFactory.getLog(getClass());

	/**
	 * 获得当前绑定的ioSession
	 * 
	 * @return
	 */
	protected IoSession getCurrentSession() {
		return SessionUtils.getCurrentSession();
	}

	/**
	 * 获得当前的用户
	 * 
	 * @return
	 */
	protected GameUser getCurrentUser() {
		return (GameUser) getCurrentSession().getAttribute(SessionUtils.USER);
	}

	/**
	 * 获得当前角色
	 * 
	 * @return
	 */
	protected Player getCurrentPlayer() {
		return (Player) getCurrentSession().getAttribute(SessionUtils.PLAYER);
	}
}
